changed smax value from 7 to 6 in functions.r
